/**
 * 
 */
package edu.ou.cs.youming.agents;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Map;
import java.util.Random;

import edu.ou.cs.youming.jaxb.types.Dictionary;
import edu.ou.cs.youming.jaxb.types.Feature;
import edu.ou.cs.youming.jaxb.types.Label;

/**
 * @author Youming Lin
 * 
 */
public final class RandomAgent implements Agent {
	private final Random random;
	private final EnumSet<Label> labels;

	public RandomAgent(final EnumSet<Label> labels) {
		if (labels == null) {
			throw new NullPointerException("labels");
		}

		random = new Random(System.nanoTime());
		this.labels = labels;
	}

	@Override
	public final void train(final Map<Feature, Label> features, final Dictionary dict) {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see edu.ou.cs.youming.agents.Agent#predict(edu.ou.cs.youming.jaxb.types.Feature)
	 */
	@Override
	public final Label predict(final Feature feature) {
		return new ArrayList<Label>(labels).get(random.nextInt(labels.size()));
	}
}